#include <gtest/gtest.h>
#include "CommandLineArgsParser.h"

class ArgsParserTest : public ::testing::Test {
};

TEST_F(ArgsParserTest, TestHelp) {
    char * argv[2];
    argv[0] = "progName";
    argv[1] = "-help";
    int argc = 2;
    CommandLineArgsParser parser(argc, (char **) &argv);
    ASSERT_TRUE(parser.isUsageMessage());
    ASSERT_FALSE(parser.isErrorMessage());
}

TEST_F(ArgsParserTest, TestEmptyArgs) {
    char * argv[1];
    argv[0] = "progName";
    int argc = 1;
    CommandLineArgsParser parser(argc, (char **) &argv);
    ASSERT_FALSE(parser.isUsageMessage());
    ASSERT_TRUE(parser.isErrorMessage());
}

TEST_F(ArgsParserTest, TestInputOutputArgs) {
    char * argv[6];
    argv[0] = "-input";
    argv[1] = ".";
    argv[2] = "-output";
    argv[3] = ".";
    argv[4] = "-dim";
    argv[5] = "4";
    int argc = 6;
    CommandLineArgsParser parser(argc, (char **) &argv);
    ASSERT_FALSE(parser.isUsageMessage());
    ASSERT_FALSE(parser.isErrorMessage());
    ASSERT_TRUE(parser.getDimensions() == 4);
    ASSERT_TRUE(parser.getInputPath() != NULL);
    ASSERT_TRUE(parser.getOutputPath() != NULL);
}

TEST_F(ArgsParserTest, TestInputInputtOutputArgs) {
    char * argv[8];
    argv[0] = "-inputt";
    argv[1] = ".";
    argv[2] = "-input";
    argv[3] = ".";
    argv[4] = "-output";
    argv[5] = ".";
    argv[6] = "-dim";
    argv[7] = "4";
    int argc = 8;
    CommandLineArgsParser parser(argc, (char **) &argv);
    ASSERT_FALSE(parser.isUsageMessage());
    ASSERT_FALSE(parser.isErrorMessage());
    ASSERT_TRUE(parser.getDimensions() == 4);
    ASSERT_TRUE(parser.getInputPath() != NULL);
    ASSERT_TRUE(parser.getOutputPath() != NULL);
}

int main(int argc, char ** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
